<!DOCTYPE html>
<html lang="zh-CN">
<meta charset="utf-8" />
<head>
<title>区域管理 <?php echo $this->config->item('title');?>
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="<?php echo base_url()?>public/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php echo base_url()?>public/css/style.css">

</head>
<body>
	<script src="<?php echo base_url()?>public/js/jquery-2.0.2.min.js"></script>
	<script src="<?php echo base_url()?>public/js/bootstrap.min.js"></script>
	<script src="<?php echo base_url()?>public/js/bootstrap-confirm.js"></script>
	<script src="<?php echo base_url()?>public/js/ssi_common.js"></script>
	<div role="navigation" class="navbar navbar-inverse navbar-fixed-top">
		<div class="container">
			<div class="navbar-header">
				<a class="navbar-brand">SSI后台管理系统</a>
			</div>
			<div class="collapse navbar-collapse navbar-right">
				<ul class="nav navbar-nav">
					<li><a href="<?php echo base_url()?>" class="navbar-link">首页</a></li>
					<li><a href="<?php echo base_url()."index.php/common_login_user_set"?>" class="navbar-link">超级管理员</a></li>
					<li><a href="<?php echo base_url()?>index.php/common_login_manage/logout" class="navbar-link">退出</a></li>
				</ul>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-xs-3">
				<?php echo $user_menu?>
			</div>
			<div class="col-xs-9">
				<div class="panel panel-default">
					<div class="panel-heading">
						<div class="pull-right">
						<?php if ($add_region) {?>
								<a href="<?php echo base_url()."index.php/sys_region_manage/add_region"?>" class="btn btn-link"><span
								class="glyphicon glyphicon-plus"> </span><span>添加</span> </a>
						<?php }?>
						</div>
						<?php if ($query_region) {?>
						<form method="post" enctype="multipart/form-data" role="form"
							class="form-inline">
							<div class="form-group">
								<label for="parent1">上级区域&nbsp;</label> 
								<select id="parent1"
									name="parent1" onchange="onParent1Changed()"
									class="form-control"><option value="0" selected>无</option>
									<?php if ($top_regions!=null) {
										foreach ($top_regions as $top_region){?>
										<option value="<?php echo $top_region['region_id']?>" <?php echo $top_region['region_id']==$top_region_id?'selected="selected"':''?> ><?php echo $top_region['region_name']?></option>;
									
									<?php }
									}?>
									
								</select>
								
							</div>
							<?php if ($second_regions!=null) {?>
							<div class="form-group">
								<label for="parent2" class="sr-only">二级区域 </label>
								<select id="parent2"
									name="parent2" onchange="onParent2Changed()"
									class="form-control">
									<option value="0" selected>无</option>
									<?php foreach ($second_regions as $region){?>
										<option value="<?php echo $region['region_id']?>" <?php echo $region['region_id']==$second_region_id?'selected="selected"':''?> ><?php echo $region['region_name']?></option>;
									<?php }?>
								</select>
							</div>
							<?php }?>
						</form>
						<?php }?>
					</div>
					<div class="panel-body">
					
						<?php if ($query_region) {?>
						<table class="table table-hover">
							<thead>
								<tr>
									<td class="col-sm-10"><b>名称</b></td>
									<td class="col-sm-2"><b>操作</b></td>
								</tr>
							</thead>
							<tbody id="content_table">
								<?php for ($i = 0; $i < count($regions); $i++) {?>
								<tr>
									<td>
										<?php if ($has_link){?>
										<a href='<?php echo base_url()."index.php"?>/sys_region_manage?region_id=<?php echo $regions[$i]['region_id']?>'><?php echo $regions[$i]['region_name']?></a>
										<?php }else{?>
										<?php echo $regions[$i]['region_name']?>
										<?php }?>
									</td>
									<td>
									
										<?php if ($update_region) {?>
										<a class='btn btn-link comfirm' title='编辑' href='<?php echo base_url()."index.php"?>/sys_region_manage/edit_region?id=<?php echo $regions[$i]['region_id']?>'>
										<span class='glyphicon glyphicon-pencil'></span></a>
										<?php }?>
										<?php if ($delete_region) {?>
										<a class='btn btn-link comfirm delete_link' title='删除' rel='<?php echo base_url()."index.php"?>/sys_region_manage/delete_region?id=<?php echo $regions[$i]['region_id']?>'>
										<span class='glyphicon glyphicon-trash'></span></a> 
										<?php }?>
									</td>
								</tr>
								<?php }?>
							</tbody>
							<?php }?>
						</table>
					</div>
				</div>
				<script>
				jQuery(function($) {
					$(".delete_link").each(function() {
					   $(this).confirm({
					    'title' : '是否确认删除',
					    'message' : '是否确认删除这个区域?',
					    'action' : $(this).attr('rel')
					   });
					});
					
				});
				function onParent1Changed(){
				 var href='<?php echo base_url()."index.php"?>/sys_region_manage';
				 var parent1 = $("#parent1");
				 var index = parent1.get(0).selectedIndex;
				 if (index > 0) {
				  href = href + "?region_id=" + parent1.val();
				 }
				 window.location.href = href;
				}
				function onParent2Changed(){
				 var href='<?php echo base_url()."index.php"?>/sys_region_manage';
				 var parent2 = $("#parent2");
				 var index = parent2.get(0).selectedIndex;
				 if (index > 0) {
				  href = href + "?region_id=" + parent2.val();
				  window.location.href = href;
				  return;
				 }
				 
				 onParent1Changed();
				}
			
			</script>
			</div>
		</div>
	</div>
	
<div  class="back-to" id="toolBackTop">
	<a title="返回顶部" onclick="window.scrollTo(0,0);return false;" href="#top" class="back-top">
	返回顶部</a>
	<a title="返回底部" onclick="window.scrollTo(0,document.body.scrollHeight);return false;" href="#bottom" class="back-bottom">
	返回底部</a>
</div>

	
</body>
</html>
